<!DOCTYPE html>
<html lang="zh-CN" data-theme="light">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <meta name="generator" content="VuePress 2.0.0-beta.51" />
    <meta name="theme" content="VuePress Theme Hope" />
    <meta property="og:url" content="https://pro.autojs.org/docs/zh/v8/plugins.html">
    <meta property="og:site_name" content="Auto.js Pro文档">
    <meta property="og:title" content="plugins - 插件">
    <meta property="og:type" content="article">
    <meta property="og:updated_time" content="2022-10-22T12:28:46.000Z">
    <meta property="og:locale" content="zh-CN">
    <meta property="og:locale:alternate" content="en-US">
    <meta property="article:modified_time" content="2022-10-22T12:28:46.000Z">
    <link rel="alternate" hreflang="en-us" href="https://pro.autojs.org/docs/en/zh/v8/plugins.html">
    <link rel="icon" href="https://pro.autojs.org/docs/favicon.ico">
    <link rel="manifest" href="https://pro.autojs.org/docs/manifest.webmanifest" crossorigin="use-credentials">
    <meta name="theme-color" content="#46bd87">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
    <title>plugins - 插件 | Auto.js Pro文档</title>
    <meta name="description" content="支持Node.js的自动化工作流JavaScript IDE">
    <style>
        :root {
            --bg-color: #fff;
        }

        html[data-theme="dark"] {
            --bg-color: #1d2025;
        }

        html,
        body {
            background-color: var(--bg-color);
        }
    </style>
    <script>
        const userMode = localStorage.getItem("vuepress-theme-hope-scheme");
        const systemDarkMode =
            window.matchMedia &&
            window.matchMedia("(prefers-color-scheme: dark)").matches;

        if (userMode === "dark" || (userMode !== "light" && systemDarkMode)) {
            document.querySelector("html").setAttribute("data-theme", "dark");
        }
    </script>
    <link rel="stylesheet" href="../../assets/style.ae9cb182.css">
    <link rel="modulepreload" href="../../assets/app.6aa2b576.js">
    <link rel="modulepreload" href="../../assets/plugins.html.6a5740b4.js">
    <link rel="modulepreload" href="../../assets/_plugin-vue_export-helper.cdc0426e.js">
    <link rel="modulepreload" href="../../assets/plugins.html.c48d9e7b.js">
</head>

<body>


    <!-- Copyright � 2008. Spidersoft Ltd -->
    <style>
        A.applink:hover {
            border: 2px dotted #DCE6F4;
            padding: 2px;
            background-color: #ffff00;
            color: green;
            text-decoration: none
        }

        A.applink {
            border: 2px dotted #DCE6F4;
            padding: 2px;
            color: #2F5BFF;
            background: transparent;
            text-decoration: none
        }

        A.info {
            color: #2F5BFF;
            background: transparent;
            text-decoration: none
        }

        A.info:hover {
            color: green;
            background: transparent;
            text-decoration: underline
        }
    </style>


    <div id="app"><!--[--><!--[--><!--[--><span tabindex="-1"></span><a href="#main-content"
            class="skip-link sr-only">Skip to content</a><!--]-->
        <div class="theme-container has-toc"><!--[--><!--[-->
            <header class="navbar">
                <div class="navbar-left"><button class="toggle-sidebar-button" title="Toggle Sidebar"><span
                            class="icon"></span></button><!----><a href="../../docs.html" class="brand"><img
                            class="logo" src="../../logo.png" alt="Auto.js Pro文档"><!----><span
                            class="site-name hide-in-pad">Auto.js Pro文档</span></a><!----></div>
                <div class="navbar-center"><!---->
                    <nav class="nav-links">
                        <div class="nav-item hide-in-mobile"><a href="../../docs.html" class="nav-link"
                                aria-label="Auto.js Pro"><span class="icon iconfont icon-home"></span>Auto.js
                                Pro<!----></a></div>
                        <div class="nav-item hide-in-mobile"><a href="../guide/guide.html" class="nav-link"
                                aria-label="指南"><span class="icon iconfont icon-creative"></span>指南<!----></a></div>
                        <div class="nav-item hide-in-mobile"><a href="v8.html" class="nav-link active"
                                aria-label="第一代API文档"><span class="icon iconfont icon-note"></span>第一代API文档<!----></a>
                        </div>
                        <div class="nav-item hide-in-mobile"><a href="../v9/v9.html" class="nav-link"
                                aria-label="第二代API文档"><span class="icon iconfont icon-note"></span>第二代API文档<!----></a>
                        </div>
                        <div class="nav-item hide-in-mobile">
                            <div class="dropdown-wrapper"><button class="dropdown-title" type="button"
                                    aria-label="官网与相关链接"><span class="title"><span
                                            class="icon iconfont icon-discover"></span>官网与相关链接</span><span
                                        class="arrow"></span>
                                    <ul class="nav-dropdown">
                                        <li class="dropdown-item"><a href="../../../pro.autojs.html"
                                                rel="noopener noreferrer" target="_blank" aria-label="官网与软件下载"
                                                class="nav-link"><!---->官网与软件下载<span><svg class="external-link-icon"
                                                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                                                        focusable="false" x="0px" y="0px" viewBox="0 0 100 100"
                                                        width="15" height="15">
                                                        <path fill="currentColor"
                                                            d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                                        </path>
                                                        <polygon fill="currentColor"
                                                            points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                                        </polygon>
                                                    </svg><span class="external-link-icon-sr-only">open in new
                                                        window</span></span><!----></a></li>
                                        <li class="dropdown-item"><a href="https://blog.autojs.org/"
                                                rel="noopener noreferrer" target="_blank" aria-label="官方博客"
                                                class="nav-link"><!---->官方博客<span><svg class="external-link-icon"
                                                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                                                        focusable="false" x="0px" y="0px" viewBox="0 0 100 100"
                                                        width="15" height="15">
                                                        <path fill="currentColor"
                                                            d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                                        </path>
                                                        <polygon fill="currentColor"
                                                            points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                                        </polygon>
                                                    </svg><span class="external-link-icon-sr-only">open in new
                                                        window</span></span><!----></a></li>
                                        <li class="dropdown-item"><a href="https://pd.qq.com/s/gosos5"
                                                rel="noopener noreferrer" target="_blank" aria-label="官方频道"
                                                class="nav-link"><!---->官方频道<span><svg class="external-link-icon"
                                                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                                                        focusable="false" x="0px" y="0px" viewBox="0 0 100 100"
                                                        width="15" height="15">
                                                        <path fill="currentColor"
                                                            d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                                        </path>
                                                        <polygon fill="currentColor"
                                                            points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                                        </polygon>
                                                    </svg><span class="external-link-icon-sr-only">open in new
                                                        window</span></span><!----></a></li>
                                    </ul>
                                </button></div>
                        </div>
                    </nav><!---->
                </div>
                <div class="navbar-right"><!---->
                    <div class="nav-item">
                        <div class="dropdown-wrapper i18n-dropdown"><button class="dropdown-title" type="button"
                                aria-label="选择语言"><!--[--><svg xmlns="http://www.w3.org/2000/svg" class="icon i18n-icon"
                                    viewBox="0 0 1024 1024" fill="currentColor" aria-label="i18n icon"
                                    style="width:1rem;height:1rem;vertical-align:middle;">
                                    <path
                                        d="M379.392 460.8 494.08 575.488l-42.496 102.4L307.2 532.48 138.24 701.44l-71.68-72.704L234.496 460.8l-45.056-45.056c-27.136-27.136-51.2-66.56-66.56-108.544h112.64c7.68 14.336 16.896 27.136 26.112 35.84l45.568 46.08 45.056-45.056C382.976 312.32 409.6 247.808 409.6 204.8H0V102.4h256V0h102.4v102.4h256v102.4H512c0 70.144-37.888 161.28-87.04 210.944L378.88 460.8zM576 870.4 512 1024H409.6l256-614.4H768l256 614.4H921.6l-64-153.6H576zM618.496 768h196.608L716.8 532.48 618.496 768z">
                                    </path>
                                </svg><!--]--><span class="arrow"></span>
                                <ul class="nav-dropdown">
                                    <li class="dropdown-item"><a href="../../en/en.html" class="nav-link"
                                            aria-label="English"><!---->English<!----></a></li>
                                    <li class="dropdown-item"><a aria-current="page" href="plugins.html"
                                            class="router-link-active router-link-exact-active nav-link active"
                                            aria-label="简体中文"><!---->简体中文<!----></a></li>
                                </ul>
                            </button></div>
                    </div><!---->
                    <div class="nav-item hide-in-mobile"><button id="appearance-switch"><svg
                                xmlns="http://www.w3.org/2000/svg" class="icon auto-icon" viewBox="0 0 1024 1024"
                                fill="currentColor" aria-label="auto icon" style="display:block;">
                                <path
                                    d="M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z">
                                </path>
                            </svg><svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" viewBox="0 0 1024 1024"
                                fill="currentColor" aria-label="dark icon" style="display:none;">
                                <path
                                    d="M524.8 938.667h-4.267a439.893 439.893 0 0 1-313.173-134.4 446.293 446.293 0 0 1-11.093-597.334A432.213 432.213 0 0 1 366.933 90.027a42.667 42.667 0 0 1 45.227 9.386 42.667 42.667 0 0 1 10.24 42.667 358.4 358.4 0 0 0 82.773 375.893 361.387 361.387 0 0 0 376.747 82.774 42.667 42.667 0 0 1 54.187 55.04 433.493 433.493 0 0 1-99.84 154.88 438.613 438.613 0 0 1-311.467 128z">
                                </path>
                            </svg><svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon"
                                viewBox="0 0 1024 1024" fill="currentColor" aria-label="light icon"
                                style="display:none;">
                                <path
                                    d="M952 552h-80a40 40 0 0 1 0-80h80a40 40 0 0 1 0 80zM801.88 280.08a41 41 0 0 1-57.96-57.96l57.96-58a41.04 41.04 0 0 1 58 58l-58 57.96zM512 752a240 240 0 1 1 0-480 240 240 0 0 1 0 480zm0-560a40 40 0 0 1-40-40V72a40 40 0 0 1 80 0v80a40 40 0 0 1-40 40zm-289.88 88.08-58-57.96a41.04 41.04 0 0 1 58-58l57.96 58a41 41 0 0 1-57.96 57.96zM192 512a40 40 0 0 1-40 40H72a40 40 0 0 1 0-80h80a40 40 0 0 1 40 40zm30.12 231.92a41 41 0 0 1 57.96 57.96l-57.96 58a41.04 41.04 0 0 1-58-58l58-57.96zM512 832a40 40 0 0 1 40 40v80a40 40 0 0 1-80 0v-80a40 40 0 0 1 40-40zm289.88-88.08 58 57.96a41.04 41.04 0 0 1-58 58l-57.96-58a41 41 0 0 1 57.96-57.96z">
                                </path>
                            </svg></button></div>
                    <div class="search-box" role="search" data-v-f3875574><input value="" aria-label="Search" class=""
                            placeholder="Search" autocomplete="off" spellcheck="false" data-v-f3875574><!----></div>
                    <!----><button class="toggle-navbar-button" aria-label="Toggle Navbar" aria-expanded="false"
                        aria-controls="nav-screen"><span class="button-container"><span class="button-top"></span><span
                                class="button-middle"></span><span class="button-bottom"></span></span></button>
                </div>
            </header><!----><!--]--><!---->
            <div class="toggle-sidebar-wrapper"><span class="arrow left"></span></div>
            <aside class="sidebar"><!--[--><!----><!--]-->
                <ul class="sidebar-links">
                    <li>
                        <section class="sidebar-group">
                            <p class="sidebar-heading"><!----><span class="title">指南</span><!----></p>
                            <ul class="sidebar-links">
                                <li><!--[--><a href="v8.html" class="nav-link sidebar-link sidebar-page"
                                        aria-label="阅读须知"><!---->阅读须知<!----></a>
                                    <ul class="sidebar-sub-headers"></ul><!--]-->
                                </li>
                            </ul>
                        </section>
                    </li>
                    <li>
                        <section class="sidebar-group">
                            <p class="sidebar-heading"><!----><span class="title">API文档</span><!----></p>
                            <ul class="sidebar-links">
                              <li>
                                <section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span
                                      class="title">自动化 -
                                      控件操作</span><span class="arrow down"></span></button>
                                  <ul class="sidebar-links">
                                    <li><!--[--><a href="./automator/"
                                        class="router-link-active router-link-exact-active nav-link sidebar-link sidebar-page"
                                        aria-label="入门介绍" aria-current="page"><!---->入门介绍<!----></a>
                                      <ul class="sidebar-sub-headers"></ul><!--]-->
                                    </li>
                                    <li><!--[--><a href="./automator/selector.html" class="nav-link sidebar-link sidebar-page"
                                        aria-label="选择器"><!---->选择器<!----></a>
                                      <ul class="sidebar-sub-headers"></ul><!--]-->
                                    </li>
                                    <li><!--[--><a href="./automator/uiobject.html" class="nav-link sidebar-link sidebar-page"
                                        aria-label="控件和控件集合"><!---->控件和控件集合<!----></a>
                                      <ul class="sidebar-sub-headers"></ul><!--]-->
                                    </li>
                                    <li><!--[--><a href="./automator/api.html" class="nav-link sidebar-link sidebar-page"
                                        aria-label="automator与其他函数"><!---->automator与其他函数<!----></a>
                                      <ul class="sidebar-sub-headers"></ul><!--]-->
                                    </li>
                                  </ul>
                                </section>
                              </li>
                              <li><!--[--><a href="./coordinatesBasedAutomation.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="自动化 - 坐标操作"><!---->自动化 -
                                  坐标操作<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./app.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="app - 应用"><!---->app -
                                  应用<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./base64.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="base64"><!---->base64<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./colors.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="colors - 颜色"><!---->colors - 颜色<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./canvas.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="canvas - 画布"><!---->canvas - 画布<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./console.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="console - 控制台"><!---->console - 控制台<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./crypto.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="crypto - 加解密与消息摘要"><!---->crypto - 加解密与消息摘要<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./debug.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="debug - 调试工具"><!---->debug - 调试工具<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./device.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="device - 设备"><!---->device - 设备<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./dialogs.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="dialogs - 对话框"><!---->dialogs - 对话框<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./engines.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="engines - 脚本引擎"><!---->engines - 脚本引擎<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./events.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="events - 事件与监听"><!---->events - 事件与监听<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./floaty.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="floaty - 悬浮窗"><!---->floaty - 悬浮窗<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./files.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="files - 文件系统"><!---->files - 文件系统<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./globals.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="globals - 全局变量与函数"><!---->globals - 全局变量与函数<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./http.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="http - HTTP网络请求"><!---->http - HTTP网络请求<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./images.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="images - 图片处理"><!---->images - 图片处理<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./keys.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="keys - 按键模拟"><!---->keys
                                  - 按键模拟<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./media.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="media - 多媒体"><!---->media
                                  - 多媒体<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./modules.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="module - 模块"><!---->module - 模块<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./ocr.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="ocr - 文字识别"><!---->ocr -
                                  文字识别<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./plugins.html" class="nav-link sidebar-link sidebar-page active"
                                  aria-label="plugins - 插件"><!---->plugins - 插件<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./powerManager.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="power_manager - 电源管理"><!---->power_manager - 电源管理<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./sensors.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="sensors - 传感器"><!---->sensors - 传感器<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./shell.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="shell - Shell命令"><!---->shell - Shell命令<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./storages.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="storages - 本地存储"><!---->storages - 本地存储<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./settings.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="settings - 设置"><!---->settings - 设置<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./threads.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="threads - 多线程"><!---->threads - 多线程<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./timers.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="timers - 定时器"><!---->timers - 定时器<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./timedTasks.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="work_manager - 定时与任务"><!---->work_manager - 定时与任务<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li>
                                <section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span
                                      class="title">ui - 用户界面</span><span class="arrow down"></span></button>
                                  <ul class="sidebar-links">
                                    <li><a href="/docs_bak/zh/v8/ui/ui.html" class="nav-link sidebar-link sidebar-page"
                                           aria-label="ui入门介绍"><!---->ui入门介绍<!----></a>
                                      <ul class="sidebar-sub-headers"></ul>
                                    </li>
                                    <li><a href="/docs_bak/zh/v8/ui/basic.html" class="nav-link sidebar-link sidebar-page"
                                           aria-label="基础布局与控件"><!---->基础布局与控件<!----></a>
                                      <ul class="sidebar-sub-headers"></ul>
                                    </li>
                                    <li><a href="/docs_bak/zh/v8/ui/advanced.html" class="nav-link sidebar-link sidebar-page"
                                           aria-label="其他布局与控件"><!---->其他布局与控件<!----></a>
                                      <ul class="sidebar-sub-headers"></ul>
                                    </li>
                                    <li><a href="/docs_bak/zh/v8/ui/api.html" class="nav-link sidebar-link sidebar-page"
                                           aria-label="api文档"><!---->api文档<!----></a>
                                      <ul class="sidebar-sub-headers"></ul>
                                    </li>
                                    <li><a href="/docs_bak/zh/v8/ui/customWidget.html" class="nav-link sidebar-link sidebar-page"
                                           aria-label="自定义控件"><!---->自定义控件<!----></a>
                                      <ul class="sidebar-sub-headers"></ul>
                                    </li>
                                    <li><a aria-current="page" href="/docs_bak/zh/v8/ui/webview.html"
                                        class="router-link-active router-link-exact-active nav-link sidebar-link sidebar-page"
                                        aria-label="使用Web编写界面"><!---->使用Web编写界面<!----></a>
                                      <ul class="sidebar-sub-headers"></ul>
                                    </li>
                                  </ul>
                                </section>
                              </li>
                              <li><!--[--><a href="./util.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="util - 工具"><!---->util -
                                  工具<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./webSocket.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="WebSocket"><!---->WebSocket<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                              <li><!--[--><a href="./zip.html" class="nav-link sidebar-link sidebar-page"
                                  aria-label="zip - 压缩与解压"><!---->zip -
                                  压缩与解压<!----></a>
                                <ul class="sidebar-sub-headers"></ul><!--]-->
                              </li>
                            </ul>
                          </section>
                    </li>
                    <li>
                        <section class="sidebar-group">
                            <p class="sidebar-heading"><!----><span class="title">进阶</span><!----></p>
                            <ul class="sidebar-links">
                                <li><!--[--><a href="scriptingJava.html" class="nav-link sidebar-link sidebar-page"
                                        aria-label="和Java交互"><!---->和Java交互<!----></a>
                                    <ul class="sidebar-sub-headers"></ul><!--]-->
                                </li>
                            </ul>
                        </section>
                    </li>
                </ul><!--[--><!----><!--]-->
            </aside><!--[-->
            <main class="page" id="main-content"><!--[--><!---->
                <nav class="breadcrumb disable"></nav>
                <div class="page-title">
                    <h1><!---->plugins - 插件</h1>
                    <div class="page-info"><span class="date-info" aria-label="写作日期📅" data-balloon-pos="down"><svg
                                xmlns="http://www.w3.org/2000/svg" class="icon calendar-icon" viewBox="0 0 1024 1024"
                                fill="currentColor" aria-label="calendar icon">
                                <path
                                    d="M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 01-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 01-33.473-33.473V143.657H180.6A134.314 134.314 0 0046.66 277.595v535.756A134.314 134.314 0 00180.6 947.289h669.74a134.36 134.36 0 00133.94-133.938V277.595a134.314 134.314 0 00-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 01-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 01-33.472 33.473z">
                                </path>
                            </svg><span>2022年10月22日</span>
                            <meta property="datePublished" content="2022-10-22T07:36:15.000Z">
                        </span></div>
                    <hr>
                </div>
                <div class="toc-place-holder">
                    <aside id="toc">
                        <div class="toc-header">此页内容</div>
                        <div class="toc-wrapper">
                            <ul class="toc-list"><!--[-->
                                <li class="toc-item"><a aria-current="page"
                                        href="https://pro.autojs.org/docs/zh/v8/plugins.html#plugins-load-packagename"
                                        class="router-link-active router-link-exact-active toc-link level2">$plugins.load(packageName)</a>
                                </li><!----><!--]--><!--[-->
                                <li class="toc-item"><a aria-current="page"
                                        href="https://pro.autojs.org/docs/zh/v8/plugins.html#如何开发一个插�?"
                                        class="router-link-active router-link-exact-active toc-link level2">如何开发一个插件</a>
                                </li>
                                <ul class="toc-list"><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#插件sdk集成"
                                            class="router-link-active router-link-exact-active toc-link level3">插件SDK集成</a>
                                    </li><!----><!--]--><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#插件配置"
                                            class="router-link-active router-link-exact-active toc-link level3">插件配置</a>
                                    </li><!----><!--]-->
                                </ul><!--]--><!--[-->
                                <li class="toc-item"><a aria-current="page"
                                        href="https://pro.autojs.org/docs/zh/v8/plugins.html#ocr插件"
                                        class="router-link-active router-link-exact-active toc-link level2">OCR插件</a>
                                </li>
                                <ul class="toc-list"><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#new-ocr-datafile-lang"
                                            class="router-link-active router-link-exact-active toc-link level3">new
                                            OCR([dataFile, lang])</a></li><!----><!--]--><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#ocr-ocrfile-path"
                                            class="router-link-active router-link-exact-active toc-link level3">OCR.ocrFile(path)</a>
                                    </li><!----><!--]--><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#ocr-ocrimage-img"
                                            class="router-link-active router-link-exact-active toc-link level3">OCR.ocrImage(img)</a>
                                    </li><!----><!--]--><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#ocr-ocrscreen"
                                            class="router-link-active router-link-exact-active toc-link level3">OCR.ocrScreen()</a>
                                    </li><!----><!--]--><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#ocr-ocrbitmap-bitmap"
                                            class="router-link-active router-link-exact-active toc-link level3">OCR.ocrBitmap(bitmap)</a>
                                    </li><!----><!--]--><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#ocr-end"
                                            class="router-link-active router-link-exact-active toc-link level3">OCR.end()</a>
                                    </li><!----><!--]--><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#ocrresult"
                                            class="router-link-active router-link-exact-active toc-link level3">OcrResult</a>
                                    </li><!----><!--]--><!--[-->
                                    <li class="toc-item"><a aria-current="page"
                                            href="https://pro.autojs.org/docs/zh/v8/plugins.html#ocrword"
                                            class="router-link-active router-link-exact-active toc-link level3">OcrWord</a>
                                    </li><!----><!--]-->
                                </ul><!--]--><!--[-->
                                <li class="toc-item"><a aria-current="page"
                                        href="https://pro.autojs.org/docs/zh/v8/plugins.html#第三方插�?"
                                        class="router-link-active router-link-exact-active toc-link level2">第三方插件</a>
                                </li><!----><!--]-->
                            </ul>
                        </div>
                    </aside>
                </div><!---->
                <div class="theme-hope-content">
                    <h1 id="plugins-插件" tabindex="-1"><a class="header-anchor" href="#plugins-插件"
                            aria-hidden="true">#</a> plugins - 插件</h1>
                    <p>Auto.js提供了加载插件的机制，允许用户编写带有Activity, Service, C/C++库等的apk，安装到Android设备上，并用Auto.js加载和调用。</p>
                    <p>一个插件是一个可独立安装的apk文件，用户安装后，再通过<code><span class="token property">$plugins</span></code>模块加载插件和调用其中的API。
                    </p>
                    <p>从Pro 9.2开始，插件支持打包时合并到apk中，打包后无需再单独安装插件。</p>
                    <div class="custom-container tip">
                        <p class="custom-container-title">提示</p>
                        <p>Pro 9.2中，Auto.js Pro应用内置了插件商店，现在可在插件商店下载插件，参见博客<a
                                href="https://blog.autojs.org/2022/09/13/pro-9-2-release-notes/" target="_blank"
                                rel="noopener noreferrer">Auto.js Pro 9.2版本正式发布<span><svg class="external-link-icon"
                                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px"
                                        y="0px" viewBox="0 0 100 100" width="15" height="15">
                                        <path fill="currentColor"
                                            d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                        </path>
                                        <polygon fill="currentColor"
                                            points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                        </polygon>
                                    </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>。
                        </p>
                    </div>
                    <h2 id="plugins-load-packagename" tabindex="-1"><a class="header-anchor"
                            href="#plugins-load-packagename" aria-hidden="true">#</a> $plugins.load(packageName)</h2>
                    <ul>
                        <li><code><span class="token property">packageName</span></code> {string} 加载的插件包名</li>
                    </ul>
                    <p>加载一个插件，并返回插件模块中module.exports导出的对象。</p>
                    <p>如果插件未安装，则抛出<code><span class="token property">PluginLoadException</span></code>异常。</p>
                    <p>以下为一个OCR插件的使用例子：(插件下载地址参见<a href="#ocr%E6%8F%92%E4%BB%B6">OCR插件</a>，<strong>从Pro
                            9.2开始不推荐使用该插件，官方内置了更强的OCR插件</strong>)。</p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code><span class="token function">requestScreenCapture</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">let</span> <span class="token constant">OCR</span> <span class="token operator">=</span> $plugins<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span><span class="token string">&#39;org.autojs.plugin.ocr&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> ocr <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OCR</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 截取屏幕并对屏幕文字进行识别，返回识别结果</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>ocr<span class="token punctuation">.</span><span class="token function">ocrScreen</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h2 id="如何开发一个插件" tabindex="-1"><a class="header-anchor" href="#如何开发一个插件" aria-hidden="true">#</a>
                        如何开发一个插件</h2>
                    <div class="custom-container tip">
                        <p class="custom-container-title">提示</p>
                        <p>以下示例代码可在这里找到完整项目：<a href="https://github.com/hyb1996/Auto.js-Plugin-SDK" target="_blank"
                                rel="noopener noreferrer">插件SDK<span><svg class="external-link-icon"
                                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px"
                                        y="0px" viewBox="0 0 100 100" width="15" height="15">
                                        <path fill="currentColor"
                                            d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                        </path>
                                        <polygon fill="currentColor"
                                            points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                        </polygon>
                                    </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>
                        </p>
                    </div>
                    <p>本示例中的包名均为<code>org<span class="token punctuation">.</span>autojs<span class="token punctuation">.</span>plugin<span class="token punctuation">.</span>sdk<span class="token punctuation">.</span>demo</code>，在实际项目中插件包名可能有所不同。
                    </p>
                    <h3 id="插件sdk集成" tabindex="-1"><a class="header-anchor" href="#插件sdk集成" aria-hidden="true">#</a>
                        插件SDK集成</h3>
                    <p>新建一个Android项目，在项目的build.gradle文件中添加：</p>
                    <div class="language-groovy ext-groovy line-numbers-mode">
                        <pre class="language-groovy"><code>allprojects <span class="token punctuation">{</span>
    repositories <span class="token punctuation">{</span>
        <span class="token comment">// ...</span>
        maven <span class="token punctuation">{</span> url <span class="token string">&#39;https://jitpack.io&#39;</span> <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <p>在具体模块(比如app)的build.gradle文件中添加：</p>
                    <div class="language-groovy ext-groovy line-numbers-mode">
                        <pre class="language-groovy"><code>dependencies <span class="token punctuation">{</span>
    <span class="token comment">// ... </span>
    implementation <span class="token string">&#39;com.github.hyb1996:Auto.js-Plugin-SDK:0.2&#39;</span>
<span class="token punctuation">}</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <p>更多信息参见<a href="https://jitpack.io/#hyb1996/Auto.js-Plugin-SDK/0.2" target="_blank"
                            rel="noopener noreferrer">Jitpack.io<span><svg class="external-link-icon"
                                    xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px"
                                    y="0px" viewBox="0 0 100 100" width="15" height="15">
                                    <path fill="currentColor"
                                        d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                    </path>
                                    <polygon fill="currentColor"
                                        points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                    </polygon>
                                </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>。</p>
                    <h3 id="插件配置" tabindex="-1"><a class="header-anchor" href="#插件配置" aria-hidden="true">#</a> 插件配置</h3>
                    <h4 id="_1-新建pluginhelloworld文件-继承于plugin" tabindex="-1"><a class="header-anchor"
                            href="#_1-新建pluginhelloworld文件-继承于plugin" aria-hidden="true">#</a> 1.
                        新建<code><span class="token property">PluginHelloWorld</span></code>文件，继承于Plugin.</h4>
                    <div class="language-java ext-java line-numbers-mode">
                        <pre class="language-java"><code><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">PluginHelloWorld</span> <span class="token keyword">extends</span> <span class="token class-name">Plugin</span> <span class="token punctuation">{</span>

    <span class="token keyword">public</span> <span class="token class-name">PluginHelloWorld</span><span class="token punctuation">(</span><span class="token class-name">Context</span> context<span class="token punctuation">,</span> <span class="token class-name">Context</span> selfContext<span class="token punctuation">,</span> <span class="token class-name">Object</span> runtime<span class="token punctuation">,</span> <span class="token class-name">Object</span> topLevelScope<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">super</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> selfContext<span class="token punctuation">,</span> runtime<span class="token punctuation">,</span> topLevelScope<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// 返回插件的JavaScript胶水层代码的assets目录路径</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">getAssetsScriptDir</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token string">&quot;plugin-helloworld&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// 插件public API，可被JavaScript代码调用</span>
    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">getStringFromJava</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token string">&quot;Hello, Auto.js!&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// 插件public API，可被JavaScript代码调用</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">say</span><span class="token punctuation">(</span><span class="token class-name">String</span> message<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token function">getSelfContext</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">startActivity</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Intent</span><span class="token punctuation">(</span><span class="token function">getSelfContext</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>  <span class="token class-name">HelloWorldActivity</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">putExtra</span><span class="token punctuation">(</span><span class="token string">&quot;message&quot;</span><span class="token punctuation">,</span> message<span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">addFlags</span><span class="token punctuation">(</span><span class="token class-name">Intent</span><span class="token punctuation">.</span><span class="token constant">FLAG_ACTIVITY_NEW_TASK</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h4 id="_2-新增mypluginregistry文件-继承于pluginregistry" tabindex="-1"><a class="header-anchor"
                            href="#_2-新增mypluginregistry文件-继承于pluginregistry" aria-hidden="true">#</a> 2.
                        新增<code><span class="token property">MyPluginRegistry</span></code>文件，继承于PluginRegistry:</h4>
                    <div class="language-java ext-java line-numbers-mode">
                        <pre class="language-java"><code><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MyPluginRegistry</span> <span class="token keyword">extends</span> <span class="token class-name">PluginRegistry</span> <span class="token punctuation">{</span>

    <span class="token keyword">static</span> <span class="token punctuation">{</span>
        <span class="token comment">// 注册默认插件</span>
        <span class="token function">registerDefaultPlugin</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">PluginLoader</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token annotation punctuation">@Override</span>
            <span class="token keyword">public</span> <span class="token class-name">Plugin</span> <span class="token function">load</span><span class="token punctuation">(</span><span class="token class-name">Context</span> context<span class="token punctuation">,</span> <span class="token class-name">Context</span> selfContext<span class="token punctuation">,</span> <span class="token class-name">Object</span> runtime<span class="token punctuation">,</span> <span class="token class-name">Object</span> topLevelScope<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">PluginHelloWorld</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> selfContext<span class="token punctuation">,</span> runtime<span class="token punctuation">,</span> topLevelScope<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <p>在AndroidManifest.xml中配置以下meta-data,
                        <code><span class="token property">name</span></code>为<code><span class="token string">&quot;org.autojs.plugin.sdk.registry&quot;</span></code>，<code><span class="token property">value</span></code>为MyPluginRegistry的包名。
                    </p>
                    <div class="language-xml ext-xml line-numbers-mode">
                        <pre class="language-xml"><code>  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>application</span>
        <span class="token attr-name">...</span><span class="token punctuation">&gt;</span></span>

        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta-data</span>
            <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>org.autojs.plugin.sdk.registry<span class="token punctuation">&quot;</span></span>
            <span class="token attr-name"><span class="token namespace">android:</span>value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>org.autojs.plugin.sdk.demo.MyPluginRegistry<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>

        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>activity</span>
            <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>.HelloWorldActivity<span class="token punctuation">&quot;</span></span>
            <span class="token attr-name"><span class="token namespace">android:</span>exported</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>

        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>service</span>
            <span class="token attr-name"><span class="token namespace">android:</span>name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>.HelloworldPluginService<span class="token punctuation">&quot;</span></span>
            <span class="token attr-name"><span class="token namespace">android:</span>exported</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>application</span><span class="token punctuation">&gt;</span></span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h4 id="_3-编写javascript胶水层" tabindex="-1"><a class="header-anchor" href="#_3-编写javascript胶水层"
                            aria-hidden="true">#</a> 3. 编写JavaScript胶水层</h4>
                    <p>在assets的相应目录(由Plugin.getAssetsScriptDir返回)中添加<code>index<span class="token punctuation">.</span>js</code>文件，用于作为胶水层导出插件API。
                    </p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code>module<span class="token punctuation">.</span><span class="token function-variable function">exports</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">plugin</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">let</span> runtime <span class="token operator">=</span> plugin<span class="token punctuation">.</span>runtime<span class="token punctuation">;</span>
    <span class="token keyword">let</span> scope <span class="token operator">=</span> plugin<span class="token punctuation">.</span>topLevelScope<span class="token punctuation">;</span>

    <span class="token keyword">function</span> <span class="token function">helloworld</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token punctuation">}</span>

    helloworld<span class="token punctuation">.</span>stringFromJava <span class="token operator">=</span> plugin<span class="token punctuation">.</span><span class="token function">getStringFromJava</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    helloworld<span class="token punctuation">.</span><span class="token function-variable function">say</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">message</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        plugin<span class="token punctuation">.</span><span class="token function">say</span><span class="token punctuation">(</span>message<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> helloworld<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h4 id="_4-在auto-js-pro中调用" tabindex="-1"><a class="header-anchor" href="#_4-在auto-js-pro中调用"
                            aria-hidden="true">#</a> 4. 在Auto.js Pro中调用</h4>
                    <p>编译插件为apk(assembleDebug/assembleRelease)，安装到设备上。在Auto.js Pro中使用以下代码调用：</p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code><span class="token keyword">let</span> helloworld <span class="token operator">=</span> $plugins<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span><span class="token string">&quot;org.autojs.plugin.sdk.demo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>helloworld<span class="token punctuation">.</span>stringFromJava<span class="token punctuation">)</span><span class="token punctuation">;</span>
helloworld<span class="token punctuation">.</span><span class="token function">say</span><span class="token punctuation">(</span><span class="token string">&quot;Hello, Auto.js Pro Plugin&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h4 id="_5-独立服务aidl方式调用" tabindex="-1"><a class="header-anchor" href="#_5-独立服务aidl方式调用"
                            aria-hidden="true">#</a> 5. 独立服务AIDL方式调用</h4>
                    <p>可以在插件中编写一个<code><span class="token property">Service</span></code>，由Auto.js
                        Pro唤起和绑定，并可在js中通过aidl调用Service的接口。</p>
                    <p>在Plugin中重写方法<code><span class="token property">getService</span></code>。</p>
                    <div class="language-java ext-java line-numbers-mode">
                        <pre class="language-java"><code><span class="token comment">// 插件服务类，可选，用于AIDL方式和Auto.js Pro本体通信。可返回null</span>
<span class="token annotation punctuation">@Override</span>
<span class="token keyword">public</span> <span class="token class-name">ComponentName</span> <span class="token function">getService</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">ComponentName</span><span class="token punctuation">(</span><span class="token function">getSelfContext</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getPackageName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">HelloworldPluginService</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <p>新建一个Service组件（<strong>注意在AndroidManifest中注册时需要是exported=&quot;true&quot;</strong>)，继承于<code><span class="token property">PluginService</span></code>。
                    </p>
                    <div class="language-java ext-java line-numbers-mode">
                        <pre class="language-java"><code><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">HelloworldPluginService</span> <span class="token keyword">extends</span> <span class="token class-name">PluginService</span> <span class="token punctuation">{</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> <span class="token constant">ACTION_ADD</span> <span class="token operator">=</span> <span class="token string">&quot;add&quot;</span><span class="token punctuation">;</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">protected</span> <span class="token class-name">Result</span> <span class="token function">onRemoteCall</span><span class="token punctuation">(</span><span class="token annotation punctuation">@NonNull</span> <span class="token class-name">String</span> action<span class="token punctuation">,</span> <span class="token annotation punctuation">@NonNull</span> <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> args<span class="token punctuation">,</span> <span class="token annotation punctuation">@Nullable</span> <span class="token class-name">RemoteCallback</span> callback<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">RuntimeException</span> <span class="token punctuation">{</span>
        <span class="token keyword">switch</span> <span class="token punctuation">(</span>action<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">case</span> <span class="token constant">ACTION_ADD</span><span class="token operator">:</span>
                <span class="token keyword">return</span> <span class="token function">invokeAdd</span><span class="token punctuation">(</span>args<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token class-name">Result</span><span class="token punctuation">.</span><span class="token function">notImplemented</span><span class="token punctuation">(</span>action<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">private</span> <span class="token class-name">Result</span> <span class="token function">invokeAdd</span><span class="token punctuation">(</span><span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">Number</span> a   <span class="token operator">=</span> <span class="token class-name">PluginUtils</span><span class="token punctuation">.</span><span class="token function">getNotNull</span><span class="token punctuation">(</span>args<span class="token punctuation">,</span> <span class="token string">&quot;a&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Number</span> b   <span class="token operator">=</span> <span class="token class-name">PluginUtils</span><span class="token punctuation">.</span><span class="token function">getNotNull</span><span class="token punctuation">(</span>args<span class="token punctuation">,</span> <span class="token string">&quot;b&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">double</span> sum <span class="token operator">=</span> a<span class="token punctuation">.</span><span class="token function">doubleValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> b<span class="token punctuation">.</span><span class="token function">doubleValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Result</span><span class="token punctuation">(</span><span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonMap</span><span class="token punctuation">(</span><span class="token string">&quot;sum&quot;</span><span class="token punctuation">,</span> sum<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <p>在index.js中添加胶水层代码:</p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code>helloworld<span class="token punctuation">.</span><span class="token function-variable function">remoteAdd</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">a<span class="token punctuation">,</span> b</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> plugin<span class="token punctuation">.</span><span class="token function">waitForConnection</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token string">&#39;add&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token literal-property property">a</span><span class="token operator">:</span> a<span class="token punctuation">,</span>
        <span class="token literal-property property">b</span><span class="token operator">:</span> b
    <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&#39;sum&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <p>然后可以在Auto.js Pro中调用：</p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code><span class="token keyword">let</span> helloworld <span class="token operator">=</span> $plugins<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span><span class="token string">&quot;org.autojs.plugin.sdk.demo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>helloworld<span class="token punctuation">.</span><span class="token function">remoteAdd</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h2 id="ocr插件" tabindex="-1"><a class="header-anchor" href="#ocr插件" aria-hidden="true">#</a> OCR插件
                    </h2>
                    <p>目前Auto.js官方仅提供一个简单的OCR插件作为示例，其效率相对较慢，仅为参考。<strong>该插件仅支持32位，Pro
                            9以上可能无法使用，推荐用官方内置ocr模块代替</strong>。</p>
                    <div class="custom-container warning">
                        <p class="custom-container-title">注意</p>
                        <p>从Pro 9.2开始不推荐使用该插件，官方内置了更强的OCR插件，比如<a href="https://pro.autojs.org/zh/ocr" target="_blank"
                                rel="noopener noreferrer">内置$ocr模块<span><svg class="external-link-icon"
                                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px"
                                        y="0px" viewBox="0 0 100 100" width="15" height="15">
                                        <path fill="currentColor"
                                            d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                        </path>
                                        <polygon fill="currentColor"
                                            points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                        </polygon>
                                    </svg><span class="external-link-icon-sr-only">open in new
                                        window</span></span></a>和<a
                                href="https://blog.autojs.org/2022/09/04/mlkit-ocr-plugin/" target="_blank"
                                rel="noopener noreferrer">MLKit OCR插件<span><svg class="external-link-icon"
                                        xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px"
                                        y="0px" viewBox="0 0 100 100" width="15" height="15">
                                        <path fill="currentColor"
                                            d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                        </path>
                                        <polygon fill="currentColor"
                                            points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                        </polygon>
                                    </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>。
                        </p>
                    </div>
                    <p><a href="https://wws.lanzoux.com/iOfyWlpz7jc" target="_blank"
                            rel="noopener noreferrer">OCR插件下载<span><svg class="external-link-icon"
                                    xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px"
                                    y="0px" viewBox="0 0 100 100" width="15" height="15">
                                    <path fill="currentColor"
                                        d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                    </path>
                                    <polygon fill="currentColor"
                                        points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                    </polygon>
                                </svg><span class="external-link-icon-sr-only">open in new
                                    window</span></span></a>(<strong>密码: 4fw3</strong>)</p>
                    <h3 id="new-ocr-datafile-lang" tabindex="-1"><a class="header-anchor" href="#new-ocr-datafile-lang"
                            aria-hidden="true">#</a> new OCR([dataFile, lang])</h3>
                    <ul>
                        <li><code><span class="token property">dataFile</span></code> {string} 数据路径</li>
                        <li><code><span class="token property">lang</span></code> {string} 语言</li>
                    </ul>
                    <p>创建一个新的OCR对象。OCR插件使用Tesseract为引擎。构造函数的dataFile和lang参数用于使用指定的语言模型初始化Tesseract引擎。</p>
                    <p>数据路径<code><span class="token property">dataFile</span></code>必须是tessdata的父目录的路径，并且必须以/结尾。最后一个/之后的任何路径都将被忽略。
                    </p>
                    <p>要加载多种语言，例如，<code>hin <span class="token operator">+</span> eng</code>将加载北印度语和英语。</p>
                    <p>更多信息参见<a
                            href="https://github.com/rmtheis/tess-two/blob/master/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java"
                            target="_blank" rel="noopener noreferrer">TessBaseAPI<span><svg class="external-link-icon"
                                    xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px"
                                    y="0px" viewBox="0 0 100 100" width="15" height="15">
                                    <path fill="currentColor"
                                        d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                    </path>
                                    <polygon fill="currentColor"
                                        points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                    </polygon>
                                </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>。</p>
                    <p>使用自带的中文字库数据初始化OCR：</p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code><span class="token keyword">let</span> <span class="token constant">OCR</span> <span class="token operator">=</span> $plugins<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span><span class="token string">&#39;org.autojs.plugin.ocr&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> ocr <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OCR</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <p>使用自己的数据初始化OCR：</p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code><span class="token keyword">let</span> <span class="token constant">OCR</span> <span class="token operator">=</span> $plugins<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span><span class="token string">&#39;org.autojs.plugin.ocr&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> ocr <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OCR</span><span class="token punctuation">(</span><span class="token string">&quot;/sdcard/tessdata/&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;chi_sim&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h3 id="ocr-ocrfile-path" tabindex="-1"><a class="header-anchor" href="#ocr-ocrfile-path"
                            aria-hidden="true">#</a> OCR.ocrFile(path)</h3>
                    <ul>
                        <li><code><span class="token property">path</span></code> {string} 文件路径</li>
                        <li>返回 <a href="#ocrresult">OcrResult</a></li>
                    </ul>
                    <p>对图片文件path进行OCR识别，返回识别后的结果。</p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code><span class="token keyword">let</span> <span class="token constant">OCR</span> <span class="token operator">=</span> $plugins<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span><span class="token string">&#39;org.autojs.plugin.ocr&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> ocr <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OCR</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
$events<span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">&#39;exit&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    ocr<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">let</span> result <span class="token operator">=</span> ocr<span class="token punctuation">.</span><span class="token function">ocrFile</span><span class="token punctuation">(</span>$file<span class="token punctuation">.</span><span class="token function">path</span><span class="token punctuation">(</span><span class="token string">&#39;./image.png&#39;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h3 id="ocr-ocrimage-img" tabindex="-1"><a class="header-anchor" href="#ocr-ocrimage-img"
                            aria-hidden="true">#</a> OCR.ocrImage(img)</h3>
                    <ul>
                        <li><code><span class="token property">img</span></code> {Image}
                            Auto.js的图片对象，通过·$images·模块截图或者读取文件返回的对象</li>
                        <li>返回 <a href="#ocrresult">OcrResult</a></li>
                    </ul>
                    <p>对图片img进行OCR识别，返回识别后的结果。</p>
                    <div class="language-javascript ext-js line-numbers-mode">
                        <pre class="language-javascript"><code>
<span class="token function">requestScreenCapture</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">let</span> <span class="token constant">OCR</span> <span class="token operator">=</span> $plugins<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span><span class="token string">&#39;org.autojs.plugin.ocr&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> ocr <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OCR</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
$events<span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">&#39;exit&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    ocr<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">let</span> result <span class="token operator">=</span> ocr<span class="token punctuation">.</span><span class="token function">ocrImage</span><span class="token punctuation">(</span><span class="token function">captureScreen</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
                        <div class="line-numbers" aria-hidden="true">
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                            <div class="line-number"></div>
                        </div>
                    </div>
                    <h3 id="ocr-ocrscreen" tabindex="-1"><a class="header-anchor" href="#ocr-ocrscreen"
                            aria-hidden="true">#</a> OCR.ocrScreen()</h3>
                    <ul>
                        <li>返回 <a href="#ocrresult">OcrResult</a></li>
                    </ul>
                    <p>截取当前屏幕进行OCR识别，返回识别后的结果。需要先申请截图权限。</p>
                    <h3 id="ocr-ocrbitmap-bitmap" tabindex="-1"><a class="header-anchor" href="#ocr-ocrbitmap-bitmap"
                            aria-hidden="true">#</a> OCR.ocrBitmap(bitmap)</h3>
                    <ul>
                        <li><code><span class="token property">bitmap</span></code> {Bitmap} android.graphics.Bitmap对象
                        </li>
                        <li>返回 <a href="#ocrresult">OcrResult</a></li>
                    </ul>
                    <p>对图片bitmap进行OCR识别，返回识别后的结果。</p>
                    <h3 id="ocr-end" tabindex="-1"><a class="header-anchor" href="#ocr-end" aria-hidden="true">#</a>
                        OCR.end()</h3>
                    <p>结束OCR识别，回收相应的OCR对象。</p>
                    <h3 id="ocrresult" tabindex="-1"><a class="header-anchor" href="#ocrresult" aria-hidden="true">#</a>
                        OcrResult</h3>
                    <p>OCR识别返回的结果，有以下只读属性：</p>
                    <ul>
                        <li><code><span class="token property">success</span></code> {boolean} 是否识别成功</li>
                        <li><code><span class="token property">text</span></code> {string} 识别文本信息</li>
                        <li><code><span class="token property">words</span></code> {<a href="#ocrword">OcrWord</a>}
                            识别文本的列表(java.util.List对象)</li>
                        <li><code><span class="token property">timeRequired</span></code> {number} 识别耗时</li>
                    </ul>
                    <h3 id="ocrword" tabindex="-1"><a class="header-anchor" href="#ocrword" aria-hidden="true">#</a>
                        OcrWord</h3>
                    <p>OCR识别中的文本。有以下只读属性：</p>
                    <ul>
                        <li><code><span class="token property">text</span></code> {string} 识别的文本</li>
                        <li><code><span class="token property">bounds</span></code> {Rect} <a
                                href="https://developer.android.google.cn/reference/android/graphics/Rect"
                                target="_blank" rel="noopener noreferrer">android.graphics.Rect<span><svg
                                        class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                                        focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                                        <path fill="currentColor"
                                            d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                        </path>
                                        <polygon fill="currentColor"
                                            points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                        </polygon>
                                    </svg><span class="external-link-icon-sr-only">open in new
                                        window</span></span></a>对象，表示文本在图片中的位置和范围</li>
                        <li><code><span class="token property">confidences</span></code> {number}
                            0~1之间的浮点数，表示结果的可信度，数值越大结果越可靠</li>
                    </ul>
                    <h2 id="第三方插件" tabindex="-1"><a class="header-anchor" href="#第三方插件" aria-hidden="true">#</a> 第三方插件
                    </h2>
                    <p>参见章节<a href="https://pro.autojs.org/zh/thirdPartyPlugins" target="_blank"
                            rel="noopener noreferrer">第三方插件<span><svg class="external-link-icon"
                                    xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px"
                                    y="0px" viewBox="0 0 100 100" width="15" height="15">
                                    <path fill="currentColor"
                                        d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                                    </path>
                                    <polygon fill="currentColor"
                                        points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                                    </polygon>
                                </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>。</p>
                </div><!---->
                <footer class="page-meta"><!---->
                    <div class="meta-item update-time"><span class="label">上次编辑于: </span><!----></div>
                    <div class="meta-item contributors"><span class="label">贡献者: </span><!--[--><!--[--><span
                            class="contributor" title="email: 946994919@qq.com">hyb1996</span><!--]--><!--]--></div>
                </footer>
                <nav class="page-nav"><a href="modules.html" class="nav-link prev" aria-label="module - 模块">
                        <div class="hint"><span class="arrow left"></span>上一页</div>
                        <div class="link"><!---->module - 模块</div>
                    </a><a href="powerManager.html" class="nav-link next" aria-label="power_manager - 电源管理">
                        <div class="hint">下一页<span class="arrow right"></span></div>
                        <div class="link">power_manager - 电源管理<!----></div>
                    </a></nav><!----><!----><!--]-->
            </main><!--]--><!----><!--]-->
        </div><!--]--><!----><!----><!--]-->
    </div>
    <script type="module" src="../../assets/app.6aa2b576.js" defer></script>
</body>

</html>